
<div class="bjui-pageHeader">
    <form id="pagerForm" data-toggle="ajaxsearch" action="${request.getContextPath()}/OrderStatus/orderStatus" method="post">
        <div class="bjui-searchBar">
            <g:hiddenField name="SYS_QUERY_NAME" value="orderStatus" />
            <g:hiddenField name="EXPORT_CONTENT_NAME" value="Excel" />
            <label >生产订单号：</label>&nbsp;
            <input type="text" name="docId"  value="${docId}"/>

            <label >来源订单号：</label>&nbsp;
            <input type="text" name="customerOrder"  value="${customerOrder}"/>

            <label >存货编码：</label>&nbsp;
            <input type="text" name="partName" value="${partName}"/>

            <label >产品名称：</label>&nbsp;
            <input type="text" name="partDesc" value="${partDesc}"/>


            <button type="submit" class="btn-default" data-icon="search">查询</button>&nbsp;
            <button type="button" class="btn-blue" onclick="javascript:bjuiExportExl('#pagerForm','${request.getContextPath()}/BadProcessAnalysis/exportExcel')" data-icon="file-excel-o" title="导出Excel">导出</button>&nbsp;
        </div>
    </form>
</div>

<div class="bjui-pageContent">
    <g:if test="${orderStatus.size() > 0}">
        <table  data-toggle="tablefixed" data-width="100%" data-nowrap="true">
            <thead>
            <tr id="t1">
        <g:each in="${tableHeadList}" status="j" var="headInstance">
            <g:if test="${headInstance!='RN'}">
                <th  width="125"><g:message code="${headInstance}" default="${headInstance}"/></th>
            </g:if>
        </g:each>
        </tr>
        </thead>
        <tbody>
        <g:each in="${orderStatus}" status="i" var="dataInstance">
            <tr>
                <g:each in="${tableHeadList}" status="j" var="headInstance">
                    <g:if test="${headInstance=='DOC_QTY'}">
                        <td name="ORDERDOC${i}">${dataInstance["${headInstance}"]}</td>
                    </g:if>
                    <g:elseif test="${headInstance=='PRE_QTY'}">
                        <td name="ORDERPRE${i}">${dataInstance["${headInstance}"]}</td>
                    </g:elseif>
                    <g:elseif test="${headInstance=='PAUSE'||headInstance=='RUN'||headInstance=='REPAIR'||headInstance=='SHIP'||headInstance=='OUTSRC'||headInstance=='SCRAP'}">
                        <td name="ORDER${headInstance+i}">${dataInstance["${headInstance}"] }</td>
                    </g:elseif>
                    <g:elseif test="${headInstance!='RN'}">
                        <td>${dataInstance["${headInstance}"]}</td>
                    </g:elseif>
                </g:each>
            </tr>
        </g:each>
        <tr>
            <td colspan="4">小计</td>
            <td name="docShow"></td>
            <td></td>
            <td></td>
            <td></td>
            <td name="preShow"></td>
            <td name="runShow"></td>
            <td name="pauseShow"></td>
            <td name="repairShow"></td>
            <td name="scrapShow"></td>
            <td name="outsrcShow"></td>
            <td name="shipShow"></td>
        </tr>
        <tr>
            <td colspan="4">合计</td>
            <td>${orderStatusSumQty.SUM_DOC_QTY[0]}</td>
            <td></td>
            <td></td>
            <td></td>
            <td>${orderStatusSumQty.SUM_PRE_QTY[0]}</td>
            <td>${orderStatusSumQty.SUM_RUN[0]}</td>
            <td>${orderStatusSumQty.SUM_PAUSE[0]}</td>
            <td>${orderStatusSumQty.SUM_REPAIR[0]}</td>
            <td>${orderStatusSumQty.SUM_SCRAP[0]}</td>
            <td>${orderStatusSumQty.SUM_OUTSRC[0]}</td>
            <td>${orderStatusSumQty.SUM_SHIP[0]}</td>

        </tr>
    </g:if>
</tbody>
</table>
</div>
<g:render template="../template/pagination" />
<script>
    $(function(){
        var orderDoc=0;
        var orderPre=0;
        var orderPause=0;
        var orderRun=0;
        var orderHold=0;
        var orderRepair=0;
        var orderOutsrc=0;
        var orderScrap=0;
        var orderShip=0;
        for(var i=0;i<${orderStatus.size()};i++){

            var doc='ORDERDOC'+i
            var docAdd=$("td[name='"+doc+"']").text()==''?0:parseInt($("td[name='"+doc+"']").text());
            orderDoc+=docAdd;

            var pre='ORDERPRE'+i
            var preAdd=$("td[name='"+pre+"']").text()==''?0:parseInt($("td[name='"+pre+"']").text());
            orderPre+=preAdd;

            var pause='ORDERPAUSE'+i
            var pauseAdd=$("td[name='"+pause+"']").text()==''?0:parseInt($("td[name='"+pause+"']").text());
            orderPause+=pauseAdd;

            var run='ORDERRUN'+i
            var runAdd=$("td[name='"+run+"']").text()==''?0:parseInt($("td[name='"+run+"']").text());
            orderRun+=runAdd;
//
            var hold='ORDERHOLD'+i
            var holdAdd=$("td[name='"+hold+"']").text()==''?0:parseInt($("td[name='"+hold+"']").text());
            orderHold+=holdAdd;

            var repair='ORDERREPAIR'+i
            var repairAdd=$("td[name='"+repair+"']").text()==''?0:parseInt($("td[name='"+repair+"']").text());
            orderRepair+=repairAdd;

            var outsrc='ORDEROUTSRC'+i
            var outsrcAdd=$("td[name='"+outsrc+"']").text()==''?0:parseInt($("td[name='"+outsrc+"']").text());
            orderOutsrc+=outsrcAdd;

            var scrap='ORDERSCRAP'+i
            var scrapAdd=$("td[name='"+scrap+"']").text()==''?0:parseInt($("td[name='"+scrap+"']").text());
            orderScrap+=scrapAdd;

            var ship='ORDERSHIP'+i
            var shipAdd=$("td[name='"+ship+"']").text()==''?0:parseInt($("td[name='"+ship+"']").text());
            orderShip+=shipAdd;

        }



        $("td[name='docShow']").html(orderDoc);
        $("td[name='preShow']").html(orderPre);
        $("td[name='pauseShow']").html(orderPause);
        $("td[name='runShow']").html(orderRun);
        $("td[name='holdShow']").html(orderHold);
        $("td[name='repairShow']").html(orderRepair);
        $("td[name='outsrcShow']").html(orderOutsrc);
        $("td[name='scrapShow']").html(orderScrap);
        $("td[name='shipShow']").html(orderShip);

    })
</script>
